﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Estimate.Common.DataFileFinder;
using Estimate.Common.DataImporter;
using System.Configuration;
using Estimate.Common.Estimate;
using Estimate.Common.Entity;
using Estimate.Common.DBFieldTypes;
using Estimate.Common.Repository;
using Estimate.Common;
using Estimate.Reports;
using log4net;

[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace ExportSubForeFile
{
    class Program
    {
        static void Main(string[] args)
        {

            ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            DataImporterCombiner combiner = new DataImporterCombiner(ConfigurationManager.AppSettings);

            try
            {
                Console.WriteLine();
                Console.WriteLine("===================={0}===================", "正在生成主观预报评分样本文件");

                //主观预报评分样本文件
                string beginDate = ConfigurationManager.AppSettings["SubjectiveForecastScore_BegineDate"];
                DateTime BeginDate = DateTime.Today;
                if (beginDate != "")
                    BeginDate = DateTime.Parse(beginDate);
                string directory = ConfigurationManager.AppSettings["SubjectiveForecastScore_Directory"];
                string semiType = ConfigurationManager.AppSettings["SubjectiveForecastScore_SemiType"];
                string rankType = ConfigurationManager.AppSettings["SubjectiveForecastScore_CollectionRankType"];
                ForeSemiType foreSemiType = (ForeSemiType)Enum.Parse(typeof(ForeSemiType), semiType);
                CollectionRankType collectionRankType = (CollectionRankType)Enum.Parse(typeof(CollectionRankType), rankType);
                string sendPoint = "";//发报时刻，H08或H28
                if (args != null && args.Length > 0)
                    sendPoint = args[0];
                AutoBuildSubjectiveForecastScoreFile ExportSubjectiveForecastScore = new AutoBuildSubjectiveForecastScoreFile(ConfigurationManager.AppSettings["ConnectionString"], collectionRankType);
                ExportSubjectiveForecastScore.EmptySemisDirectory = ConfigurationManager.AppSettings["EmptySemisDirectory"];
                ExportSubjectiveForecastScore.GetSubjectiveForecastScoreXML(BeginDate, foreSemiType, directory, sendPoint);

                Console.WriteLine();
                Console.WriteLine("===================={0}===================", "数据生成完成");

            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
    }
}
